<template>
  <div class="app-container">
    <el-table :row-style="{ height: '25px' }"  :cell-style="{ padding: '0px' }" border v-loading="loading" :data="enrollList">
      <el-table-column
        label="序号" type="index" :index="indexMethod"/>
      <el-table-column label="问卷调查名称" align="center" prop="questionnaireName" />
      <el-table-column label="发送企业" align="center" prop="deptName" :show-overflow-tooltip="true"/>
      <el-table-column label="作答人员" align="center" prop="personnelName" />
      <el-table-column label="职务" align="center" prop="personnelDuties" />
      <el-table-column label="联系电话" align="center" prop="personnelContact" />
      <el-table-column label="问卷得分" align="center" prop="questionnaireScore" />
      <el-table-column label="查看" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-orange"
            @click="handleSelect(scope.row)"
          >查看</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
    <el-dialog title="问卷调查" :visible.sync="openAnswer"  width="700px"   append-to-body v-if="openAnswer">
      <answer :questionnaireId="questionnaireId" @change="closeAnswer()" :selectType="1"  :orgId="orgId"></answer>
    </el-dialog>
  </div>
</template>
<script >
import { listEnroll, selectIsAnswer, delEnroll, addEnroll, updateEnroll } from "@/api/questionnaire/enroll";
import Answer from "../reception/answer.vue";
export default {
  name: "return",
  components: {Answer},
  props:{
    questionnaireId:{
      type: String,
      default: null
    }
  },
  data() {
    return {
      // 遮罩层
      loading: true,
      // 总条数
      total: 0,
      // 问卷调查作答表格数据
      enrollList: [],
      //当前企业机构id
      orgId:null,
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 15,
        questionnaireId: null
      },
      openAnswer:false,
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询问卷调查作答列表 */
    getList() {
      this.loading = true;
      this.queryParams.questionnaireId=this.questionnaireId
      selectIsAnswer(this.queryParams).then(response => {
        this.enrollList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    closeAnswer(){
      this.openAnswer=false;
      this.orgId=null;
      this.questionnaireId=null;
    },
    /**
     * 查看问卷
     */
    handleSelect(row){
     this.questionnaireId=row.questionnaireId;
     this.orgId=row.answerEnterpriseId;
     this.openAnswer=true;
    },
    //序号展示
    indexMethod(index){
      return (this.queryParams.pageNum-1)*this.queryParams.pageSize +index+1;
    },
  }
};

</script>
<style scoped lang="scss">

</style>
